﻿using SafoverWpfFw;
using System;
using System.Globalization;
using System.Net;

namespace Safover.LidarCollector.Converter
{
    public class IPAddressToStringConverter : BaseValueConverter<IPAddressToStringConverter>
    {
        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            IPAddress ipAddress = value as IPAddress;

            return ipAddress != null ? ipAddress.ToString() : null;
        }

        public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            _ = IPAddress.TryParse(value as string, out IPAddress ipAddress);

            return ipAddress;
        }
    }
}
